<template>
  <div class="common-layout mainContainer">
    <el-container>
      <el-header></el-header>
      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" stretch>
        <el-tab-pane label="会员专区" name="first">
          <!--          会员专区-->
          <el-card>
            <div
                class="vip"
                v-if="num === 0"
            >
              <p>会员专区</p>
              <div class="vip_content">
                <div class="vip_content_photo">
                  <img
                      src="https://rs.dance365.com/default_head@3x.png?imageView2/0/w/100/h/100/format/webp/ignore-error/1"
                      alt="个人头像"
                  >
                </div>
                <div class="vip_content_container">
                  <div
                      class="vip_content_container_left"
                  >
                    <div class="vip_content_container_left_name">ruiruirui<span><i class="lv"></i><i
                        class="lv1"
                    ></i></span>
                    </div>
                    <div class="vip_content_container_left_vip-tip">开通会员尊享10大特权</div>
                  </div>
                  <div class="vip_content_container_center">
                    <span class="vip_content_container_center_icon"><img
                        src="https://rs.dance365.com/teach_video_free.png"></span>
                    <p>
                      以下<i>723</i>个会员专区课程
                      <br>全部免费学习
                    </p>
                  </div>
                  <div
                      class="vip_content_container_right"
                  >
                    <span class="vip_content_container_right_icon"><img
                        src="https://rs.dance365.com/member_preferential.png"></span>
                    <p>
                      购买非会员专区课程
                      <br>可获会员立减优惠
                    </p>
                  </div>
                </div>
                <div
                    class="vip_content_open"
                    v-show="float"
                >
                  <el-button
                      type="primary"
                      round
                      color="#F93684"
                  ><span class="open">立即开通</span></el-button>
                  <span class="check">查看/开通></span>
                </div>
              </div>
            </div>
          </el-card>
          <!--          兴趣技能，价格区间-->
          <el-card class="hobbyList_card">
            <div v-for="item in searchList" :id="item.name">
              <el-row :gutter="20">
                <el-col :span="2" class="text">
                  <div class="hobbyList_name">{{item.label}}</div>
                </el-col>
                <el-col :span="22" class="text_comtents">
                  <div v-for="choise in item.choises" :id="choise.id" @click="isActive">{{choise.name}}</div>
                </el-col>
              </el-row>
            </div>
            <p class="show">
                <span style="cursor: pointer;" @click="showAll">
                  <span v-if="show">收起</span>
                  <span v-else>展开</span>
                  <i class="el-icon-arrow-down" v-if="show"></i>
                  <i class="el-icon-arrow-right" v-else></i>
                </span>
            </p>
          </el-card>
          <!--          综合排序区域-->
          <el-card>
            <div class="works">
              <div>综合排序</div>
              <div>销量</div>
              <div>浏览量</div>
              <el-dropdown>
                       <span class="el-dropdown-link">价格<el-icon class="el-icon--right">
                         <arrow-down/></el-icon>
                          </span>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item command="a">由高到低</el-dropdown-item>
                    <el-dropdown-item command="b">由低到高</el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
              <div>发布时间</div>
            </div>
          </el-card>

          <!--          视频展示区域-->
          <Video v-for="item in MultipleConditionsList" :key="item" :item="item"></Video>

          <!--          回到顶部-->
          <el-backtop :bottom="180" :right="150">
            <div
                style="
        height: 100%;
        width: 100%;
        background-color: #F93684;
        box-shadow: var(--el-box-shadow-lighter);
        text-align: center;
        line-height: 40px;
        color: #1989fa;
        border-radius: 50%;
      "
            >
              🐇
            </div>
          </el-backtop>
        </el-tab-pane>
        <el-tab-pane label="视频课" name="second">
          <VideoClass></VideoClass>
        </el-tab-pane>
        <el-tab-pane label="直播课" name="third">
          <LiveClass></LiveClass>
        </el-tab-pane>
        <el-tab-pane label="线下课" name="fourth">
          <offline-class></offline-class>
        </el-tab-pane>
        <el-tab-pane label="主题" name="theme">
          <theme></theme>
        </el-tab-pane>
      </el-tabs>
      <el-footer></el-footer>
    </el-container>
  </div>
</template>

<script lang="ts">
import {defineComponent} from "vue";

export default defineComponent({
  name: "Discovery",
});
</script>

<script setup lang="ts">
import { ElMessage } from 'element-plus'
import {onMounted, ref,watch} from 'vue'
import type {TabsPaneContext} from 'element-plus'
import VideoClass from "@/views/discovery/videoclass/index.vue";
import LiveClass from "@/views/discovery/liveclass/index.vue";
import OfflineClass from "@/views/discovery/offlineclass/index.vue";
import Theme from "@/views/discovery/theme/index.vue";
import {reqVipCourseList,reqVipSearchList,reqVipSearchPrice} from "@/api/discovery";
const activeName = ref('first')

//多条件课程列表
const MultipleConditionsList = ref([])



// 点击a标签拥有active类名,再次点击移除active类名，最多可以同时拥有三个active类名，同时提醒用户最多只能选择三个兴趣技能
const isActive = (e: any) => {
  const target = e.target
  const parent = target.parentNode
  const children = parent.children
  const length = children.length
  let count = 0
  for (let i = 0; i < length; i++) {
    if (children[i].classList.contains('active')) {
      count++
    }
  }
  if (count < 3) {
    target.classList.toggle('active')
  } else {
    ElMessage(`最多只能选择三个${parent.previousElementSibling.innerText}`)
    if (target.classList.contains('active')) {
      target.classList.toggle('active')
    }
  }
}

const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event)
}
const num = ref(0)
const float = ref(true)
//价格区间
const form = ref({
  region: ''
})
// 视频卡片大小
const size = ref(34)
// 控制收起展开
const show = ref(false)

const showAll = () => {
  show.value = !show.value
  if (show.value) {
    getVipSearchList(1)
  } else {
    getVipSearchList(0)
  }

}
//动态搜索条件列表
const searchList = ref([])

// 进入页面请求数据
const getVipCourseList = async () => {
  const res = await reqVipCourseList(1,4)
  MultipleConditionsList.value = res.data.data.content.content
  console.log(MultipleConditionsList.value,'多条件课程列表')

}

const getVipSearchList = async (i:any) => {
  const res = await reqVipSearchList()
  if (i === 0) {
    searchList.value = res.data.data.slice(0, 2)
  } else {
    searchList.value = res.data.data
  }

}
const getVipSearchPrice = async () => {
  const res = await reqVipSearchPrice(1,4)
  console.log(res,'请求获取会员专区_多条件搜索_价格')
}
onMounted(() => {
  getVipCourseList()
  getVipSearchList(0)
  getVipSearchPrice()
})



</script>

<style>
body {
  /*灰色背景*/
  background-color: #f5f5f5;
}
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 16px;
  /*居中*/
}

.el-tabs__item.is-active {
  /*字体加粗*/
  font-weight: bold;
  color: pink;
}

.el-tabs__active-bar {
  height: 4px;
  background-color: #111111;
}
</style>
<style scoped>

.active{
  border-radius: 4px;
  background-color: #f93684;
  color: #fff;
}
.mainContainer {
  min-height: 900px;
  height: 100%;
  margin: 10px auto;
  width: 1200px;
}
.example-showcase .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}

* {
  margin: 0;
  padding: 0;
}

.vip {
  width: 1140px;
  height: 120px;
  margin: 0 auto;
  color: #111;
  background-color: #fff;
  margin-top: 15px;
  margin-bottom: 10px;
  border-radius: 4px;
  padding: 20px 30px 16px;

}

/* 会员专区文字 */
.vip p {
  width: 1140px;
  font-size: 18px;
  margin: 0 0 16px;
  font-weight: 400;
}

/* 头像同级大容器 */
.vip_content {
  height: 70px;
  position: relative;
  min-height: 50px;
  display: flex;
  align-items: center;
  /* background-color: #bfc; */
}

/* 小头像 */
.vip_content_photo {
  margin-right: 10px;
  width: 50px;
  height: 50px;
}

.vip_content_photo img {
  width: 50px;
  height: 50px;
  border-radius: 50%;;
}

/* 文字导航下单会员专区容器 */
.vip_content_container {
  display: flex;
  align-items: center;
}

/* 会员专区个人信息 左*/
.vip_content_container_left {
  width: 220px;
  height: 46px;
  border-right: 1px solid #ddd;
}

.vip_content_container_left_name {
  width: 220px;
  height: 24px;
  padding-top: 4px;
  font-size: 16px;
  float: left;
}

.vip_content_container_left_name span {
  display: block;
  width: 41px;
  height: 20px;
  box-sizing: border-box;
  background: linear-gradient(#ff289b, #ff43d0);
  border: 1px solid #fff;
  border-radius: 4px;
  padding: 0 8px;
  display: inline-block !important;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  margin-left: 8px;
}

.vip_content_container_left_name span i {
  width: 8px;
  height: 10px;
  display: inline-block;
  background-size: 100%;
  background-repeat: no-repeat;
}

.vip_content_container_left_name .lv {
  width: 15px;
  height: 10px;
  background-image: url(https://rs.dance365.com/level_Lv.@3x.png);

}

.vip_content_container_left_name .lv1 {
  background-image: url(https://rs.dance365.com/level_num_1@3x.png);

}

.vip_content_container_left_vip-tip {
  width: 220px;
  height: 14px;
  margin-top: 8px;
  font-size: 12px;
  color: #f93684;
}


/*会员专区个人信息  中 */
.vip_content_container_center {
  width: 333px;
  height: 69px;
  /* background-color: hotpink; */
  display: flex;
  flex: 1;
  text-align: center;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.vip_content_container_center_icon {
  width: 58px;
  height: 58px;
  margin-left: 50px;
  margin-right: 30px;
}

/* 图片*/
.vip_content_container_center_icon img {
  width: 58px;
  display: inline-block;
}

/*文字 */
.vip_content_container_center p {
  padding-top: 8px;
}

.vip_content_container_center p i {
  color: #f93684;
}

/*会员专区个人信息  右 */
.vip_content_container_right {
  width: 360px;
  height: 69px;
  /* background-color: yellowgreen; */
  display: flex;
  flex: 1;
  text-align: center;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.vip_content_container_right_icon {
  width: 58px;
  height: 58px;
  margin-right: 30px;
}

/*右 图片 */
.vip_content_container_right_icon img {
  width: 58px;
  margin-left: 50px;
  display: inline-block;
}

/*右 文字*/
.vip_content_container_right p {
  padding-top: 8px;
}

/* 立即开通 */
.vip_content_open {
  width: 80px;
  height: 58px;
}

.vip_content_open .open {
  font-size: 13px;
  color: #fff;
}

.vip_content_open .check {
  height: 16px;
  font-size: 12px;
  margin-top: 20px;
  color: rgb(164, 159, 159);
}


/*综合排序*/
.works {
  display: flex;
  font-size: 14px;
  color: #7D8090;
}

.works div {
  margin-left: 25px;
  margin-right: 30px;
}

.works div:hover {
  color: #f93684;
  /*变成小手*/
  cursor: pointer;
}

.works img {
  width: 10px;
  height: 10px;
  margin-left: 5px;
}


/*兴趣列表*/
.hobbyList_card {
  margin-top: 25px;
  padding: 16px 10px;
  font-size: 14px;
  margin-bottom: 10px;
}

.text {
  display: flex;
  flex-wrap: wrap;
  color: #b1b5c1;
}

.text_comtents {
  width: 100px;
  margin-bottom: 20px;
  color: #7D8090;
  display: flex;
  flex-wrap: wrap;
}

.text_comtents div {
  width: 100px;
  cursor: pointer;
  /*div内部文字居中*/
  text-align: center;
  margin:0 10px 10px 0;
}

.show {
  text-align: center;
  color: red;
  font-size: 14px;
  margin: 0 auto;
}
</style>
